package com.cly.controller;


import com.cly.domain.SysRole;
import com.cly.service.SysRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "角色管理接口")
@RestController
@RequestMapping("/sys/role")
public class SysRoleController {

    @Autowired
    private SysRoleService sysRoleService;

    /**
     * 放缓存
     * 缓存放在前面
     * @return
     */
    @GetMapping("list")
    @PreAuthorize("hasAuthority('sys:role:list')")
    @ApiOperation("全查询角色列表")
    public ResponseEntity<List<SysRole>> listRole(){
        List<SysRole> sysRoles = sysRoleService.list();
        return ResponseEntity.ok(sysRoles);
    }
}
